module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        /**
         * 合并文件任务
         */
        concat: {
            /*************************合并js************************/
            time_component: {
                src: ['<%=pkg.jsPath %>/compoments/mobiscroll.core-2.5.2.js',
                      '<%=pkg.jsPath %>/compoments/mobiscroll.core-2.5.2-zh.js',
                      '<%=pkg.jsPath %>/compoments/mobiscroll.datetime-2.5.1.js',
                      '<%=pkg.jsPath %>/compoments/mobiscroll.datetime-2.5.1-zh.js',
                      '<%=pkg.jsPath %>/compoments/mobiscroll.android-ics-2.5.2.js'],
                dest: 'static/concat_tmp/mobiscroll.js'
            },
            other_js:{
                src: ['<%=pkg.jsPath %>/common.js',
                    '<%=pkg.jsPath %>/suggest.js',
                    '<%=pkg.jsPath %>/guide.js',
                    '<%=pkg.jsPath %>/dateutil.js',
                    '<%=pkg.jsPath %>/weixinjs.js'],
                dest: 'static/concat_tmp/global.js'
            },
            /*************************合并css***********************/
            cssDate: {// 日期控件css
                src: ['<%=pkg.cssPath %>/mobiscroll.android-ics-2.5.2.css',
                      '<%=pkg.cssPath %>/mobiscroll.animation-2.5.2.css',
                      '<%=pkg.cssPath %>/mobiscroll.core-2.5.2.css'],
                dest: 'static/concat_tmp/mobiscroll.css'
            }
        },
        /**
         * 压缩文件任务
         */
        uglify: {
            time_component: {
                options: {
                    banner: '/*! mobiscroll.min.js <%= grunt.template.today("dd-mm-yyyy") %> */\n'
                },
                files: {
                    '<%=pkg.jsPath %>/min/mobiscroll.min.js': ['<%= concat.time_component.dest %>']
                }
            },
            page_src_js: {
                files: [{'<%=pkg.jsPath %>/min/faction.js': '<%=pkg.jsPath %>/pagesrc/faction.js'},
                        {'<%=pkg.jsPath %>/min/create.js': '<%=pkg.jsPath %>/pagesrc/create.js'},
                        {'<%=pkg.jsPath %>/min/create_faction_act.js': '<%=pkg.jsPath %>/pagesrc/create_faction_act.js'},
                        {'<%=pkg.jsPath %>/min/newcard.js': '<%=pkg.jsPath %>/pagesrc/newcard.js'},
                        {'<%=pkg.jsPath %>/min/newfaction.js': '<%=pkg.jsPath %>/pagesrc/newfaction.js'},
                        {'<%=pkg.jsPath %>/min/user.js': '<%=pkg.jsPath %>/pagesrc/user.js'},
                        {'<%=pkg.jsPath %>/min/actlist.js': '<%=pkg.jsPath %>/pagesrc/actlist.js'},
                        {'<%=pkg.jsPath %>/min/faction_invite.js': '<%=pkg.jsPath %>/pagesrc/faction_invite.js'},
                        {'<%=pkg.jsPath %>/min/circle.js': '<%=pkg.jsPath %>/pagesrc/circle.js'},
                        {'<%=pkg.jsPath %>/min/invite.js': '<%=pkg.jsPath %>/pagesrc/invite.js'}
                ]
            },
            global_js:{
                files: {
                    '<%=pkg.jsPath %>/min/global.min.js': ['<%= concat.other_js.dest %>']
                }
            }
        },
        /**
         * 压缩css任务
         */
        cssmin: {
          datetime: {
              src: 'static/concat_tmp/mobiscroll.css',
              dest: '<%=pkg.cssPath %>/min/mobiscroll.min.css'
          }
        },
        /**
         * 拷贝
         */
        copy: {
            copy_lib:{
                src: 'lib/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_api:{
                /*flatten: true,
                expand: true,*/
                src: 'api/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_entity:{
                src: 'entity/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_proxy:{
                src: 'proxy/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_service:{
                src: 'service/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_static:{
                src: 'static/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_utils:{
                src: 'utils/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_views: {
                src: 'views/**',
                dest: '/home/lgyhitler/work/fanjuOut/'
            },
            copy_others: {
                src: ['routes.js'],
                dest: '/home/lgyhitler/work/fanjuOut/'
            }
        }

    });
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-css');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('default', ['concat', 'uglify', 'cssmin', 'copy']);
}
